package com.heu.blood.security.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.Query;
import com.heu.blood.security.entity.BloodRightEntity;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.heu.blood.security.dao.BloodRoleDao;
import com.heu.blood.security.entity.BloodRoleEntity;
import com.heu.blood.security.service.BloodRoleService;


@Service("bloodRoleService")
public class BloodRoleServiceImpl extends ServiceImpl<BloodRoleDao, BloodRoleEntity> implements BloodRoleService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        LambdaQueryWrapper<BloodRoleEntity> queryWrapper = new LambdaQueryWrapper<>();
        if(Strings.isNotBlank((String)params.get("roleDes"))){
            queryWrapper.eq(Strings.isNotBlank((String)params.get("roleDes")),
                    BloodRoleEntity::getRoleDes,(String)params.get("roleDes"));
        }
        IPage<BloodRoleEntity> page = this.page(
                new Query<BloodRoleEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}